package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.FamilyMemberElder;
import com.zzyl.nursing.dto.BindingMemberElderDto;
import com.zzyl.nursing.dto.MemberDayDeviceDataDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo vo = familyMemberService.login(dto);
        return success(vo);
    }

    /**
     * 客户端绑定老人
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult addMember(@RequestBody BindingMemberElderDto dto){
        Integer flag = familyMemberService.bingElder(dto);
        return success();
    }

    /**
     * 客户端查看家人
     */

    @GetMapping("/my")
    public AjaxResult getMyElders(){
        List<SelectMemberElderVo> list = familyMemberService.getMyElders();
        return success(list);
    }

    /**
     * 获取老人列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list-by-page")
    public AjaxResult listByPage(Integer pageNum, Integer pageSize) {
        List<MemberElderInfoVo> list = familyMemberService.listByPage(pageNum, pageSize);
        return success(list);
    }

    /**
     * 查询健康数据
     */
    @GetMapping("/queryServiceProperties/{iotId}")
    public AjaxResult  getHealthData(@PathVariable String iotId){
        List<MemberElderHealthVo> list = familyMemberService.getHealthData(iotId);
        return success(list);
    }


    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(MemberDayDeviceDataDto dto){
        List<MemberDayDataVo> vo =familyMemberService.queryDeviceDataListByDay(dto);
        return success(vo);
    }
    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(MemberDayDeviceDataDto dto){
        List<MemberDayDataVo> vo =familyMemberService.queryDeviceDataListByWeek(dto);
        return success(vo);
    }

}
